<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>思途CMS{$coreVersion}</title>
    {template 'stourtravel/public/public_min_js'}
    {php echo Common::getScript("uploadify/jquery.uploadify.min.js,listimageup.js,jquery.validate.js"); }
    {php echo Common::getCss('uploadify.css','js/uploadify/'); }
    {php echo Common::getCss('base.css,style.css,destination_dialog_basicinfo.css'); }
</head>
<body>
   <div class="s-main">
       <div class="main-body">
           <div class="nav">
               <div class="w-set-tit bom-arrow">
                   <span data-rel="seo" class="on"><s></s>基本信息</span>
               </div>
               <div class="clear-both"></div>
           </div>
           <div class="nav-list">
               <form id="frm">
               <div class="item-one" id="item_seo">
                   <table>
                       <tr><td class="tit">名称：</td><td><input type="text" name="name" id="field_name" class="set-text-xh text_250" value="{$info['name']}"/></td></tr>
                       <tr id="item_code"><td class="tit">二字码：</td><td><input type="text" name="code" id="field_code" class="set-text-xh text_250" value="{$info['code']}"/></td></tr>
                   </table>
               </div>

               </form>
           </div>
       </div>
       <div class="save-con">
           <a href="javascript:;" class="confirm-btn">确定</a>
       </div>
   </div>
<script>
    var id = "{$info['id']}";
    $(function() {
        //确认提交
        $(document).on('click','.confirm-btn',function(){
             $("#frm").submit();
        })

        //添加二字码验证函数
        jQuery.validator.addMethod("code2", function(value, element) {
            var v = /^[a-zA-Z0-9]{2}$/;
            return this.optional(element) || (v.test(value));
        }, "二字码不正确");

        $("#frm").validate({
            rules: {
                name:
                {
                    required:true
                },
                code:{
                    required:true,
                    code2:true
                }
            },
            messages: {
                name: {
                    required:"名称不能为空"
                },
                code:
                {
                    required:"二字码不能为空",
                    code2:"格式错误"
                }
            },
            submitHandler:function(form){

                var data={};
                data.name=$("#field_name").val();
                data.code=$("#field_code").val();
                data.id=id;
                $.ajax({
                    url:SITEURL+ 'airport/ajax_airline_save',
                    type:'POST',
                    data:data,
                    dataType:'json',
                    success:function(result,textStatus,jqXHR){
                        if(result.status)
                        {
                            ST.Util.responseDialog('',true);
                        }
                    }
                })

                return false;
            }

        });


    })
</script>

</body>
</html>
